﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using T.FAS.Runtime.DataAccess.SPI;
using T.FAS.Runtime.DataAccess.ShardingRule;
using T.FAS.Runtime.DataAccess.SQLDom;

namespace T.FAS.Runtime.DataAccess.SPI
{
    /// <summary>
    /// 数据访问服务接口
    /// </summary>
    public interface IDataAccessService
    {
        #region Save

        /// <summary>
        /// 保存领域模型数据
        /// </summary>
        /// <param name="CompositeDataObjectID">领域模型ID</param>
        /// <param name="instance">对象实例</param>
        void Save(string CompositeDataObjectID, object instance, ShardingValue shardingValue = null);

        /// <summary>
        /// 保存领域模型数据
        /// </summary>
        /// <param name="CompositeDataObjectID">领域模型ID</param>
        /// <param name="instance">对象实例</param>
        void SaveBatch(string CompositeDataObjectID, List<object> instances, ShardingValue shardingValue = null);

        /// <summary>
        /// 保存领域模型数据
        /// </summary>
        /// <param name="CompositeDataObjectID">领域模型ID</param>
        /// <param name="instance">对象实例</param>
        void SaveBatch(string CompositeDataObjectID, List<object> instances, List<ShardingValue> shardingValues);

        /// <summary>
        /// 保存指定对象的数据
        /// </summary>
        /// <param name="CompositeDataObjectID">领域模型ID</param>
        /// <param name="CompositeNodeObjectID">领域对象ID</param>
        /// <param name="instance">对象实例</param>
        void Save(string CompositeDataObjectID, string CompositeNodeObjectID, object instance, ShardingValue shardingValue = null);

        /// <summary>
        /// 保存指定对象的数据
        /// </summary>
        /// <param name="CompositeDataObjectID">领域模型ID</param>
        /// <param name="CompositeNodeObjectID">领域对象ID</param>
        /// <param name="instances">对象实例</param>
        void Save(string CompositeDataObjectID, string CompositeNodeObjectID, List<object> instances, ShardingValue shardingValue = null);

        /// <summary>
        /// 保存指定对象的数据
        /// </summary>
        /// <param name="CompositeDataObjectID">领域模型ID</param>
        /// <param name="CompositeNodeObjectID">领域对象ID</param>
        /// <param name="instances">对象实例</param>
        void Save(string CompositeDataObjectID, string CompositeNodeObjectID, List<object> instances, List<ShardingValue> shardingValues);

        #endregion

        #region Update

        /// <summary>
        /// 更新领域模型数据
        /// </summary>
        /// <param name="CompositeDataObjectID">领域模型ID</param>
        /// <param name="instance">对象实例</param>
        void Update(string CompositeDataObjectID, object instance, ShardingValue shardingValue = null);

        /// <summary>
        /// 更新指定对象的数据
        /// </summary>
        /// <param name="CompositeDataObjectID">领域模型ID</param>
        /// <param name="CompositeNodeObjectID">领域对象ID</param>
        /// <param name="instance">对象实例</param>
        void Update(string CompositeDataObjectID, string CompositeNodeObjectID, object instance, ShardingValue shardingValue = null);

        #endregion

        #region Delete

        /// <summary>
        ///  删除数据
        /// </summary>
        /// <param name="CompositeDataObjectID">领域模型ID</param>
        /// <param name="dataId">数据唯一标识</param>
        /// <param name="shardingValue">分库分表键值对</param>
        void Delete(string CompositeDataObjectID, string dataId, ShardingValue shardingValue = null);

        /// <summary>
        ///  删除数据
        /// </summary>
        /// <param name="CompositeDataObjectID">领域模型ID</param>
        /// <param name="dataIds">数据唯一标识集合</param>
        /// <param name="shardingKeyValue">分库分表键值对</param>
        void Delete(string CompositeDataObjectID, IList<string> dataIds, ShardingValue shardingValue = null);

        /// <summary>
        ///  删除数据
        /// </summary>
        /// <param name="CompositeDataObjectID">领域模型ID</param>
        /// <param name="CompositeNodeObjectID">领域对象ID</param>
        /// <param name="dataId">数据唯一标识</param>
        /// <param name="shardingValue">分库分表键值对</param>
        void Delete(string CompositeDataObjectID, string CompositeNodeObjectID, string dataId, ShardingValue shardingValue = null);

        /// <summary>
        ///  删除数据
        /// </summary>
        /// <param name="CompositeDataObjectID">领域模型ID</param>
        /// <param name="CompositeNodeObjectID">领域对象ID</param>
        /// <param name="dataIds">数据唯一标识集合</param>
        /// <param name="shardingValue">分库分表键值对</param>
        void Delete(string CompositeDataObjectID, string CompositeNodeObjectID, IList<string> dataIds, ShardingValue shardingValue = null);

        #endregion

        #region Query

        /// <summary>
        /// 获取对象数据
        /// </summary>        
        /// <param name="CompositeDataObject">领域模型</param>
        /// <param name="dataId">数据唯一标识</param>
        /// <param name="shardingValue">分库分表键值对</param>
        /// <returns>对象数据</returns>
        List<DataTable> GetData(string CompositeDataObjectID, string dataId, ShardingValue shardingValue = null);

        /// <summary>
        /// 获取对象数据
        /// </summary>        
        /// <param name="CompositeDataObject">领域模型</param>
        /// <param name="CompositeNodeObject">领域对象</param>
        /// <param name="dataId">数据唯一标识</param>
        /// <param name="shardingValue">分库分表键值对</param>
        /// <returns>对象数据</returns>
        List<DataTable> GetData(string CompositeDataObjectID, string CompositeNodeObjectID, string dataId, ShardingValue shardingValue = null);

        /// <summary>
        /// 获取对象数据
        /// </summary>        
        /// <param name="CompositeDataObject">领域模型</param>
        /// <param name="dataId">数据唯一标识</param>
        /// <param name="shardingValue">分库分表键值对</param>
        /// <returns>对象数据</returns>
        List<DataTable> GetData(string CompositeDataObjectID, QueryFilter queryFilter);

        /// <summary>
        /// 获取对象数据
        /// </summary>        
        /// <param name="CompositeDataObject">领域模型</param>
        /// <param name="CompositeNodeObject">领域对象</param>
        /// <param name="queryFilter">查询条件</param>        
        /// <returns>对象数据</returns>
        List<DataTable> GetData(string CompositeDataObjectID, string CompositeNodeObjectID, QueryFilter queryFilter);
         
        #endregion
    }
}
